Conventionally, technologies of obtaining an instruction trace for the purpose of, for example, performance optimization and debugging of an operating program, have been known. The instruction trace is data in which individual instructions executed by a processor are recorded in time series. By referring to the instruction trace, it is possible to understand in detail that the processor executes which instruction in which order to operate the program. With this, appropriate measures can be taken for performance optimization and other purposes.
While obtaining an instruction trace is very effective way for optimizing program performance and other purposes as explained above, this may disadvantageously cause overhead. For example, when an instruction trace is obtained with an interrupt for each instruction, such overhead may cause the program execution time several hundreds-fold to several thousands-fold. With the program execution time at the time of obtaining an instruction trace such different from that at normal time, the obtained instruction trace cannot reflect the behavior of the program at normal time, and is inappropriate as information for understanding the behavior of the program.
As a technology for reducing overhead of a program at the time of obtaining an instruction trace, a technology of not obtaining a trace of all instructions but obtaining a trace of only the branch instructions is known. If the frequency of appearance of a branch instruction in an instruction string of a program is one in ten instructions, by obtaining a trace of only the branch instructions, overhead can be reduced to approximately 1/10. Also, once the trace of the branch instructions is obtained, it is possible to estimate to some degree which instruction is executed in which order while a branch instruction is executed by comparing the trace of the branch instructions and the instruction strings in the program.
An example of conventional technologies is disclosed in Japanese Laid-open Patent Publication No. 2002-342114.
However, even when overhead can be reduced to approximately 1/10 by obtaining a trace of only the branch instructions, the behavior at the time of obtaining a trace may be different from that at normal time depending on the program. To get around this, when the frequency of obtaining a trace is further decreased to reduce overhead, it becomes disadvantageously difficult to estimate which instruction is executed in which order among the sampled instructions.